cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0048 NEW)
project(zjtcp VERSION 0.1.0.0)

option(DEBUG "enable debug" ON)

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O0 -g -Wno-unused-but-set-variable -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Wno-unused-function -Wno-unused-variable")
# include aux cmake scripts
include("Gengetopt.cmake")
ADD_GENGETOPT_FILES(CMDLINE cmdline.ggo)

include("Findlibev.cmake")
set (EXTRALIB ${LIBEV_LIBRARY})

# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
	"${PROJECT_SOURCE_DIR}/config.h.in"
	"${PROJECT_BINARY_DIR}/config.h"
	)

include_directories("${CMAKE_CURRENT_BINARY_DIR}"
	"${PROJECT_BINARY_DIR}"
	"${PROJECT_SOURCE_DIR}")

set(RCTLD
serial.c
common.c
cmdline.c
buffer.c
main.c
)

# extra libs
find_package(Threads)
set (EXTRALIB ${EXTRALIB} ${CMAKE_THREAD_LIBS_INIT})

# target
add_executable(zjtcp ${CMDLINE} ${RCTLD} ${LIBLIST} )
target_link_libraries(zjtcp ${EXTRALIB} m)

# install
install(TARGETS zjtcp DESTINATION bin)
